package com.robot.backend.controller.pk;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.robot.backend.service.pk.pkReceiveDireService;

import java.util.Map;

@RestController
public class pkReceiveDireController {
    @Autowired
    pkReceiveDireService pkReceiveDireService;
    @PostMapping("/receiveDirecion/")
    public String receiveDireciont(@RequestParam MultiValueMap<String,String> map){//微服务收到方向
        System.out.println("收到方向");
        System.out.println(map);
        int d = Integer.parseInt(map.getFirst("d"));
        if (d < 0 || d > 3) {
            d = 0;
        }
        return pkReceiveDireService.receiveDirection(d,Integer.parseInt(map.getFirst("uid")));
    }
}
